/* eslint-disable */
const StyleLintPlugin = require('stylelint-webpack-plugin')
const packageName = require('./package.json').name

module.exports = {
  publicPath: process.env.NODE_ENV === 'production' ? '/service/knowledge' : '/',
  lintOnSave: process.env.NODE_ENV === 'production' ? false : 'default',
  productionSourceMap: false,
  configureWebpack: (config) => {
    const plugins = [
      new StyleLintPlugin({
        files: ['src/**/*.{vue,less}'],
        fix: true,
      }),
    ]
    config.optimization = {
      splitChunks: {
        cacheGroups: {
          vendors: {
            name: 'chunk-vendors',
            test: /[\/]node_modules[\/]/,
            priority: -10,
            chunks: 'initial',
          },
          common: {
            name: 'chunk-common',
            minChunks: 2,
            priority: -20,
            chunks: 'initial',
            reuseExistingChunk: true,
          },
          antv: {
            name: 'antv',
            test: /[\/]node_modules[\/]@antv[\/]/,
            chunks: 'all',
            priority: -6,
            reuseExistingChunk: true,
          },
        },
      },
    }

    config.output = { // qiankun 打包方式
      ...config.output,
      library: `${packageName}-[name]`,
      libraryTarget: 'umd',
      jsonpFunction: `webpackJsonp_${packageName}`,
    }

    return { plugins }
  },
  css: {
    loaderOptions: {
      less: {
        lessOptions: {
          modifyVars: {
            'ant-prefix': 'ant-kg-appl', // 添加antd 前缀
            'primary-color': '#5561ff',
            'link-color': '#5561ff',
            'border-radius-base': '2px',
          },
          javascriptEnabled: true,
        },
      },
    },
  },
  devServer: {
    port: process.env.VUE_APP_PORT,
    proxy: {
      '/api': {
        // target: 'http://10.101.16.85:8080/api/',// plugin server
        // target: 'http://10.5.24.17:8081', // dev
        // target: 'http://10.11.32.115:8083', // yxh
        // target: 'http://10.11.32.33:8083', // wz
        target: 'http://nebula-dev-http.lab.zjvis.net:32080/api/', // dev
        // target: 'http://10.11.13.186:8081', // qz
        // target: 'http://10.11.32.16:8081', // yb
        // target: 'http://10.11.32.85:8083', // yb
        // target: 'https://10.11.32.16:8443', // yb
        // target: 'http://10.11.32.237:8086', // yb
        // target: 'https://10.11.32.28:8443',// dzm
        // target: 'http://10.11.32.163:8081/', // zj
        // target: 'https://10.11.16.245:8443',// taotao
        // target: 'https://10.11.32.50:8443',// qcy
        // target: 'http://10.11.32.101:8081',// lwm
        // target: 'https://10.11.24.162:8443',// zh
        // target: 'http://10.11.16.95:8080',// ff
        // target: 'https://10.0.105.191:8443',
        // target: 'https://10.11.24.216:8443', // 元数据管理
        // target: 'http://10.11.16.241:8080', // 图片获取
        // target: 'https://10.11.16.243:8443', // hjh
        // target: 'https://10.11.16.241:8443', // dev-message-center
        // target: 'http://10.11.32.48:8081', // zhilin
        // target: 'http://10.11.32.80:8443', // dongziming
        // target: 'http://10.11.13.186:8082', // quzheng
        // target: 'http://10.11.33.57:8083', // chenruipeng
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          '^/api/(.*)': '/$1',
        },
      },
    },
    headers: {
      'Access-Control-Allow-Origin': '*'
    }
  },
}
